package quickcheck;

import net.java.quickcheck.Generator;
import net.java.quickcheck.generator.PrimitiveGenerators;

/**
 * A class to represent a book with an author
 * @author Virag Shah
 * @since 15 February 2011
 */
public class Book {

	/** the title of the book */
	public String title;
	/** the author of the book - an instance of 
	 * <CODE>{@link Author Author}</CODE> class */
	protected Author author;
	/** the price of the book */
	protected Double price;

	public Book() {
	}

	/**
	 * The standard full constructor
	 * @param title the title of the book
	 * @param author the author of the book
	 */
	public Book(String title, Author author) {
		this.title = title;
		this.author = author;
	}

	/**
	 * The standard full constructor
	 * @param title the title of the book
	 * @param author the author of the book
	 * @param price the price of the book
	 */
	public Book(String title, Author author, Double price) {
		this.title = title;
		this.author = author;
		this.price = price;
	}

	/**
	 * 
	 * @return
	 */
	public String getTitle() {
		return title;
	}

	/**
	 * 
	 * @return
	 */
	public Author getAuthor() {
		return author;
	}

	/**
	 * 
	 * @return
	 */
	public Double getPrice() {
		return price;
	}
}

/**
 * 
 * @author Virag
 *
 */
class BookGenerator extends Book implements net.java.quickcheck.Generator<Book> {
	Generator<String> title = PrimitiveGenerators.strings();
	Generator<Double> price = PrimitiveGenerators.doubles();

	/**
	 * 
	 */
	@Override
	public Book next() {
		return new Book(title.next(), author, price.next());
	}
}
